<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <!-- 1.导包 -->
    <script src="./bootstrap/js/jquery-1.12.4.min.js"></script>
    <script src="./bootstrap/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="./bootstrap/css/bootstrap.min.css">
    <script src="./jquery.twbsPagination.js"></script>
</head>

<body>
    <!-- 2.写html结构 -->
    <ul id="pagination" class="pagination-sm"></ul>

    <button id="btn">动态刷新总页数</button>

    <script>
        /* 3.js初始化 */
        $('#pagination').twbsPagination({
            totalPages: 35,//总页数
            startPage: 1,//起始页
            visiblePages: 6,//可见页数
            first: '首页',
            prev: '上一页',
            next: '下一页',
            last: '尾页',
            onPageClick: function (event, page) {
                $('#page-content').text('Page ' + page);
            }
        });

        //动态刷新总页数
        $('#btn').click(function () {
            //(1)先销毁旧插件
            $('#pagination').twbsPagination('destroy');
            //(2)重新初始化新插件
            $('#pagination').twbsPagination({
                totalPages: Math.ceil(Math.random() * 100),//总页数
                startPage: 1,//起始页
                visiblePages: 6,//可见页数
                first: '首页',
                prev: '上一页',
                next: '下一页',
                last: '尾页',
                onPageClick: function (event, page) {
                    $('#page-content').text('Page ' + page);
                }
            });
        });
    </script>
</body>

</html>